VERSION 5.00
Begin VB.Form frmInstall 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "RndDesk"
   ClientHeight    =   2070
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   3870
   Icon            =   "frmInstall.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2070
   ScaleWidth      =   3870
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton cmdInstall 
      Cancel          =   -1  'True
      Caption         =   "&Readme"
      Height          =   285
      Index           =   4
      Left            =   120
      TabIndex        =   5
      Top             =   960
      Width           =   3615
   End
   Begin VB.Frame fraInstall 
      Height          =   2055
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   3855
      Begin VB.CommandButton cmdInstall 
         Caption         =   "&About"
         Height          =   285
         Index           =   3
         Left            =   120
         TabIndex        =   4
         Top             =   1320
         Width           =   3615
      End
      Begin VB.CommandButton cmdInstall 
         Caption         =   "&Exit"
         Height          =   285
         Index           =   2
         Left            =   120
         TabIndex        =   3
         Top             =   1680
         Width           =   3615
      End
      Begin VB.CommandButton cmdInstall 
         Caption         =   "&Remove from actual position"
         Height          =   285
         Index           =   1
         Left            =   120
         TabIndex        =   2
         Top             =   600
         Width           =   3615
      End
      Begin VB.CommandButton cmdInstall 
         Caption         =   "&Install in actual position"
         Default         =   -1  'True
         Height          =   285
         Index           =   0
         Left            =   120
         TabIndex        =   1
         Top             =   240
         Width           =   3615
      End
   End
End
Attribute VB_Name = "frmInstall"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Const DELETE_ASK As String = "Do you want to delete the Wallpaper folder and all its item?"
Private Const MSG_SUCCESSFUL_REMOVE As String = "Remove successfull"
Private Const GO_SYSTRAY As String = "Systray"

Private Sub cmdInstall_Click(Index As Integer)
    Select Case Index
    'install
    Case 0
        'puoi continuare il programma in systray
        If cmdInstall(0).Caption <> GO_SYSTRAY Then
            Call SetRndDesk(True)
            cmdInstall(0).Caption = GO_SYSTRAY
        Else
            MousePointer = vbHourglass
            Me.Hide
            Unload Me
            Load frmChange
            MousePointer = vbNormal
        End If
    'remove
    Case 1
        Call SetRndDesk(False)
        MsgBox MSG_SUCCESSFUL_REMOVE, vbInformation, App.Title
    'esci
    Case 2
        Unload Me
    'about
    Case 3
        frmAbout.Show vbModal, Me
    'readme
    Case 4
        Call Shell(NOTEPAD_PROG & App.Path & README_TXT, vbNormalFocus)
    End Select
End Sub

'yes = se true indica di attivare l'avvio automatico
Private Function SetRndDesk(ByVal Yes As Boolean) As Boolean
    'setta l'avvio
    If ModAutoRun.SetAvvio(Yes, False, PARAM_CHANGE) Then
        If Yes Then
            'crea il folder wallpaper
            If Not DirExist(App.Path & WALLPAPER_DIR) Then
                MkDir App.Path & WALLPAPER_DIR
            End If
            'setta i menu quando clikki sul desktop
            
        Else
            'cancella i menu del desktop
            
            'chiede se cancellare la directory wallpaper
            If DirExist(App.Path & WALLPAPER_DIR) Then
                If MsgBox(DELETE_ASK, vbYesNo, App.Title) = vbYes Then
                    Kill App.Path & WALLPAPER_DIR & "*"
                    RmDir App.Path & WALLPAPER_DIR
                End If
            End If
            
            'cancella (se esiste) il file wallpaper
            If FileExist(App.Path & WALLPAPER_DEFAULT_NAME) Then
                Kill App.Path & WALLPAPER_DEFAULT_NAME
            End If
            
        End If
    End If
End Function
